package src.javaStudy.Thread.createThreadType;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @program: AlgorithmTest
 * @description:
 *
 * 继承Runnable创建线程
 *
 * @author: powerWriter
 * @create: 2019-06-28 09:40
 **/
public class SimplDemo implements Runnable{

    @Override
    public void run() {
        while(true){
            try {
                Thread.sleep(1000);	//使得线程休息时间1s
                SimpleDateFormat t=new SimpleDateFormat("yyyy-MM-dd"+"  "+"HH:mm:ss");
                String Time=t.format(new Date());//将当前时间信息赋给变量Time
                System.out.println("当前的时间为:"+Time);//输出当前时间信息
            } catch (InterruptedException e) {

                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args){
        SimplDemo simplDemo = new SimplDemo();
        new Thread(simplDemo).start();
    }
}
